<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="taxt" id="ipt">
    <button id="btn">按钮</button>
    <br>
    成绩是:<p id="con"></p>
    <script>
        var oIpt = document.getElementById("ipt");
        var oBtn = document.getElementById("btn");
        var oCon = document.getElementById("con");

        oBtn.onclick = function () {
            var userScore = +oIpt.value;
            if (!(userScore >= 0 && userScore <= 100)){
                alert("请重新输入")
                oIpt.value = "";
 
                return;
            }
            switch(parseInt(userScore / 10)){
                case 10:
                case 9:
                oCon.textContent = "S";
                    break;
                case 8:
                oCon.textContent = "A";
                    break;
                case 7:
                oCon.textContent = "B";
                    break;
                case 6:
                oCon.textContent = "C";
                    break;
                default:
                oCon.textContent = "成绩不及格";
            }
            

            /* if (userScore >= 90 && userScore <= 100){
                oCon.textContent = "S";
            }else if(userScore > 80 && userScore < 90){
                oCon.textContent = "A"
            }else if(userScore > 70 && userScore < 80){
                oCon.textContent = "B"
            }else if(userScore > 60 && userScore < 70){
                oCon.textContent = "C"
            }else{
                alert ("成绩不及格")} */
        }
    </script>
</body>
</html>





11111111111111111111111111111111